<!--
 * @Description: 门户首页预览界面
 * @Author: zhailei
 * @Date: 2021-05-20 18:13:04
 * @LastEditTime: 2021-08-06 10:07:24
 * 
 * @FilePath: \vite-demoe:\wwwroot\Vue\\-cloud-vue\src\pages\system\sysPortal\sysPortalPreview.vue
-->
<template>
  <build-modal class="k-portal-pre" :value="jsonData" ref="KPortalPreview" />
</template>
<script>
import { mapGetters } from "vuex";
import buildModal from "@/components/TopVUI/k-portal-design/build/index.vue";
// import { getQueryString } from "@/services/common";
export default {
  name: "KPortalPreview",
  components: {
    buildModal,
  },
  props: {
    data: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      jsonData: {},
    };
  },
  computed: {
    ...mapGetters(["currentProjectCode"]),
  },
  watch: {
    $route: {
      handler(val) {
        if (this.$route.meta.query?.code) {
          this.getPortalClassifyList(this.$route.meta.query.code);
        } else this.jsonData = {};
      },
      deep: true,
      immediate: true,
    },
    currentProjectCode: {
      handler(val) {},
      immediate: true,
    },
  },
  //   watch: {
  //     $route(val) {
  //       console.log(val);
  //       console.log(
  //         this.$route.matched.filter((res) => {
  //           res.path.indexOf("sysPortalPreview");
  //         })
  //       );
  //       if (this.$route.meta.query.code) {
  //         this.getPortalClassifyList(this.$route.meta.query.code);
  //       } else this.jsonData = {};
  //     },
  //   },

  mounted() {
    // if (this.$route.meta.query.code) {
    //   this.getPortalClassifyList(this.$route.meta.query.code);
    // } else this.jsonData = {};
  },
  methods: {
    getPortalClassifyList(m) {
      //根据模板分类Id获取数据
      this.$post("/system/sysPortal/getPortalJsonDataByTemplateClassiftCode", {
        templateClassiftCode: m,
      }).then((res) => {
        this.jsonData = res ?? {};
        // if (!res) {
        //   //如果门户设计为空 会造成类型错误  暂时当前判断 2023-7-17  office设计返回''
        //   res = {};
        // }
        // this.jsonData = res;
      });
    },
  },
};
</script>
<style lang="less">
.k-portal-pre {
  .grid-col {
    // margin-bottom: 24px;
  }
}
</style>
